import java.util.List;
import java.util.Scanner;
import java.util.Stack;

class Node{
    public int x;
    public int y;
    public Node(int x,int y){
        this.x=x;
        this.y=y;
    }
}
public class Main {
    public static Stack<Node> stack=new Stack();
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while(scanner.hasNext()){
            int row=scanner.nextInt();
            int col= scanner.nextInt();
            int[][] arr=new int[row][col];
            for(int i=0;i<row;i++){
                for(int j=0;j<col;j++){
                    arr[i][j]=scanner.nextInt();
                }
            }
            dfs(arr,0,0,row,col);
        }
    }
    public static void dfs(int[][] arr,int x,int y,int row,int col){
        Node node=new Node(x,y);
        stack.add(node);
        arr[x][y]=1;
        if(x==row-1&&y==col-1){
            for(Node n:stack){
                System.out.println("("+n.x+","+n.y+")");
            }
            return;
        }
        if(x+1<row&&arr[x+1][y]==0){
            dfs(arr,x+1,y,row,col);
        }
        if(y+1<col&&arr[x][y+1]==0){
            dfs(arr,x,y+1,row,col);
        }
        if(x-1>=0&&arr[x-1][y]==0){
            dfs(arr,x-1,y,row,col);
        }
        if(y-1>=0&&arr[x][y-1]==0){
            dfs(arr,x,y-1,row,col);
        }
        arr[x][y]=0;
        stack.pop();
    }








    public int getMost(int[][] board) {
        // write code here
        for(int i=1;i<board.length;i++){
            board[i][0]+=board[i-1][0];
            board[0][i]+=board[0][i-1];
        }
        for(int i=1;i<6;i++){
            for(int j=1;j<6;j++){
                board[i][j]=Math.max(board[i-1][j],board[i][j-1])+board[i][j];
            }
        }
        return board[5][5];
    }





}
